# -*- coding: utf-8 -*-

import base64

import requests

def parse_watermark(url):
    requests.get(url=url)


# 解析base64加密
def base64encode(text, reverse_):
    if reverse_ is False:
        return base64.b64encode(text.encode()).decode()
    b64_str = ""[::-1]
    r = ""  # 返回结果
    c = 3 - len(text) % 3  # b64字符串填充长度（b64默认以等号"="填充）
    p = b64_str[-1]  # 截取反向后的填充字符
    s = text + "\0" * c

    i = 0
    while i < len(s):
        if i > 0 and ((i / 3 * 4) % 76) == 0:
            r = r + "\r\n"
        n = (ord(s[i]) << 16) + (ord(s[i]) << 8) + ord(s[i + 2])
        n1 = (n >> 18) & 63
        n2 = (n >> 12) & 63
        n3 = (n >> 6) & 63
        n4 = n & 63
        r += b64_str[n1] + b64_str[n2] + b64_str[n3] + b64_str[n4]
    return (r[0:len(r) - len(p)] + p).lower()
